<?php
namespace app\common\model;

use app\extra\BaseModel;
use app\extra\DBCont;
use think\Exception;

class Player extends BaseModel
{

    public function getCoverAttr($value, $data){
        if (empty($value)){
            $value = model('Member')->where('team_id', $data['id'])->value('image');
            if (empty($value)){
                return null;
            }
        }
        return [
            'key' => $value,
            'value' => showFileUrl($value)
        ];
    }
    public function setCoverAttr($value){
        return serializeByArray($value, ',');
    }
    /**
     * 添加额外参数
     * @param $item
     */
    public function setAddedField(&$item){
        $vote = model('VoteInfo')->where('id', $item['vote_id'])->value('init_vote');
        $item['votes'] = $item['poll'] + $item['init_vote'] + $vote;
    }
}